﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace TinyEngine.Core.Services
{
    public class RenderTargetService : ITinyService
    {
        RenderTarget2D rawScene;
        public RenderTargetService()
        {
        }

        public void Register()
        {
            
        }

        public void Setup()
        {
            var device = ServiceManager.GetService<TinyGameEngine>().Device;
            var sceneMgr = ServiceManager.GetService<SceneManager>();
            if (sceneMgr.ActiveGameScene != null)
            {
                if (rawScene != null)
                    rawScene.Dispose();

                rawScene = new RenderTarget2D(device, sceneMgr.ActiveGameScene.FirstCamera.ViewPortSize.X, sceneMgr.ActiveGameScene.FirstCamera.ViewPortSize.Y);
            }
        }

        public void UnRegister()
        {
            
        }

        public RenderTarget2D RawScene
        {
            get { return rawScene; }
        }
    }
}
